package com.woniuxy.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;

/**
 * 新增实现了Serializable, UserDetails这两个接口
 * 席磊
 * 1.01
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class User implements Serializable, UserDetails {
    //主键
    private int id;
    //用户名
    private String username;
    //密码
    private String password;
    //身份证号
    private String idcard;
    //部门
    private String dep;
    //电话
    private String tel;

    /**
     * 权限
     * @return
     */
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    /**
     * 账号是否过期
     * @return
     */
    public boolean isAccountNonExpired() {
        return false;
    }

    /**
     * 账号是否锁定
     * @return
     */
    public boolean isAccountNonLocked() {
        return false;
    }

    /**
     * 密码是否过期
     * @return
     */
    public boolean isCredentialsNonExpired() {
        return false;
    }

    /**
     * 是否激活
     * @return
     */
    public boolean isEnabled() {
        return false;
    }

    /**
     * 密码
     * @return
     */
    public String getPassword(){
        return password;
    }

    /**
     * 用户名
     * @return
     */
    public String getUsername(){
        return username;
    }
    //上级
    private User leader;
    //角色
    private Role role;
}
